package com.aqie.advanced.automatic.bootstrap;

import com.aqie.advanced.automatic.condition.ConditionalOnSystemProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

// 通过名称和类型获取 helloWorld bean
@Slf4j
public class ConditionalOnSystemPropertyBootstrap {

    @Bean
    @ConditionalOnSystemProperty(name = "user.name", value = "Administrator")
    public String helloAqie(){
        return " hello AQIE";
    }
    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder(ConditionalOnSystemPropertyBootstrap.class)
                .web(WebApplicationType.NONE)
                .run(args);


        String helloAqie = context.getBean("helloAqie",String.class);
        log.info("helloWorld Bean : {}", helloAqie);
        context.close();
    }
}
